package com.arnold.test.transformations

import org.apache.spark.{SparkConf, SparkContext}

/**
  * Created by arnold.zhu on 2017/7/18.
  */
object Filter {

  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local").setAppName("Spark01Learn")
    val sc = new SparkContext(conf)

    // Spark使用parallelize方法转换成RDD
    val num = sc.parallelize(1 to 10)

    // 返回一个新的数据集，由经过func函数后返回值为true的原元素组成
    num.filter(_ % 2 == 0).foreach(println(_))
  }

}
